 <?php include 'system/application/views/header.php' ?>
<!-- content middel -->
        <table class='content-middle' align='center'>
            <tr>
                <td style="padding-right: 10px;">
                    <!-- content -->
                    <h2 class="title-master">Liên hệ</h2>
                    <hr>       
                    <div class="contact-content">
                    	<h3><?php echo $this->session->userdata('CONFIG_COMPANY_NAME')?></h3>
                    	<div><b>Địa chỉ</b> : <?php echo $this->session->userdata('CONFIG_COMPANY_ADDRESS')?></div>
                    	<div><b>Điện thoại</b> : <?php echo $this->session->userdata('CONFIG_COMPANY_PHONE')?></div>
                    	<div><b>Fax</b> : <?php echo $this->session->userdata('CONFIG_COMPANY_FAX');?></div>
                    	<div><b>Hotline</b> : <?php echo $this->session->userdata('CONFIG_COMPANY_HOTLINE');?></div>
                    	<div><b>Email</b> : <?php echo $this->session->userdata('CONFIG_COMPANY_EMAIL');?></div>
                    	<div><b>Website</b> : <?php echo $this->session->userdata('CONFIG_COMPANY_WEBSITE');?></div>
                    </div>
                    <div class="map_contact">
                    	<div id="map_canvas"></div>
                    </div>
                    <div class="clear_div"></div>
                    <h2 class="title-master">Liên hệ trực tuyến</h2>
                    <hr>                    
                    <div class="news-content">
                    	<div class="form-register">
                    		<form method="post" action="<?php echo base_url()?>lien_he" id="frm_lienhe">
                    			<div class="content-form">
                    				<img alt="" src="<?php echo base_url()?>media/images/form_contact.png">
                    				<table cellpadding="0" cellspacing="0">
                    				<?php if(!empty($msg)):?>
                    					<tr>
                    						<td colspan="4" class="msg_alert"><?php echo $msg?></td>
                    					</tr>
                    				<?php endif;?>
                    					<tr>
                    						<td colspan="4" style="text-align: right;">Vui lòng nhập đầy đủ thông tin ở vị trí có dấu (*)</td>
                    					</tr>
                    					<tr>
                    						<td>Họ tên(*)</td>
                    						<td><input type="text" name="ContactName" id="ContactName" /></td>
                    						<td>Địa chỉ</td>
                    						<td ><input type="text" name="ContactAddress" id="ContactAddress" /></td>
                   						</tr>
                    					<tr>
                    						<td>Email(*)</td>
                    						<td><input type="text" name="ContactEmail" id="ContactEmail" /></td>
                    						<td>Điện thoại</td>
                    						<td><input type="text" name="ContactPhone" id="ContactPhone" /></td>
                    						
                    					</tr>
                    					
                    					<tr>
                    						<td colspan="6">Nội dung(*)</td>
                    					</tr>
                    					<tr>
                    						<td colspan="4"><textarea name="ContactContent" id="ContactContent" rows="" cols=""></textarea> </td>
                    					</tr>
                    					<tr>
                    						<td colspan="6" style="text-align: right;">
                    							<span id="btnReset">Làm lại</span>
												<span id="btnSave">Gửi</span>
                    						</td>
                    					</tr>
                    				</table>
                    			</div>
                    		</form>
                    	</div>
                    </div>
                </td>
                <?php //$this->load->view("/home/block/right");?>
            </tr>
        </table>
            <script>
            //$(document).ready(function(){
            	$('#btnReset').corner("round 8px");
            	$('#btnSave').corner("round 8px");
            	$("#btnSave").click(function(){
            		if(validateReg()){
                		$("#frm_lienhe").submit();
            		}
                });
                $("#btnReset").click(function(){
                	$("#frm_lienhe")[0].reset();
                });
                
                function validateReg(){
					if($("#ContactName").val() == ""){
						alert("Vui lòng nhập họ tên");
						$("#ContactName").focus();
						return false;
					}
					if($("#ContactEmail").val() == "" || !checkEmail($("#ContactEmail").val())){
						alert("Vui lòng nhập email đúng");
						$("#ContactEmail").focus();
						return false;
					}
					if($("#ContactContent").val() == ""){
						alert("Vui lòng nhập nội dung");
						$("#ContactContent").focus();
						return false;
					}
					return true;
                }
                function checkEmail(email){
                	var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
                	return filter.test(email);		
				}
                
            //});
            </script>  
            <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=AIzaSyDuyfksfbmh0EDdr-yLj1BnMaxuGElE7IU" type="text/javascript"></script>
		    <script type="text/javascript">
		
		    var map = null;
		    var geocoder = null;
		
		    function initialize() {
		      if (GBrowserIsCompatible()) {
		        map = new GMap2(document.getElementById("map_canvas"));
		        map.setCenter(new GLatLng(10.815315,106.669301), 14);
				map.addControl(new GSmallMapControl());
				map.addControl(new GMapTypeControl());
		
		        geocoder = new GClientGeocoder();
		      }
		    }
		
		    function showAddress(address) {
		      if (geocoder) {
		        geocoder.getLatLng(
		          address,
		          function(point) {
		            if (!point) {
		              alert(address + " load maps have problem");
		            } else {
		              map.setCenter(point, 15);
		              var marker = new GMarker(point);
		              map.addOverlay(marker);
		
		              // As this is user-generated content, we display it as
		              // text rather than HTML to reduce XSS vulnerabilities.
		              marker.openInfoWindow( '<?php echo $this->session->userdata('CONFIG_COMPANY_NAME');?>' + '<br/>' +   address);
		            }
		          }
		        );
		      }
		    }
			initialize();
		    showAddress( "<?php echo $this->session->userdata('CONFIG_COMPANY_ADDRESS');?>" );
		    </script>    
                    <?php include 'system/application/views/footer.php' ?>